<template>
  <div>

    <!--  司机表格展示-->
    <el-table :data="driverData.items">

      <el-table-column label="用户">
        <template slot-scope="scope">
          <el-select v-model="scope.row.userId" disabled>
            <el-option v-for="(item,index) in userAllData" :key="index" :label="item.name" :value="item.id"/>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="所属车队id">
        <template slot-scope="scope">
          <el-select v-model="scope.row.fleetId" disabled>
            <el-option v-for="(item,index) in flletData" :key="index" :label="item.name" :value="item.id"/>
          </el-select>
        </template>
      </el-table-column>
      <el-table-column label="年龄" prop="age"/>
      <el-table-column label="图片" prop="picture"/>
      <el-table-column label="驾龄" prop="drivingAge"/>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="getDriverLicenseInfo(scope.row)">
            <router-link :to="'/base/driver-info/'+scope.row.userId">
              查看司机驾驶证信息
            </router-link>
          </el-button>
        </template>
      </el-table-column>
    </el-table>


    <!--   分页-->
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="Number(driverData.page)"
      :page-sizes="[5, 15, 30, 50]"
      :page-size="Number(driverData.pagesize)"
      layout="total, sizes, prev, pager, next, jumper"
      :total="Number(driverData.counts)"
    >
    </el-pagination>


    <!--    查看司机驾驶证信息-->

  </div>
</template>

<script>
import driver from '@/api/base/driver/index'
import user from '@/api/base/globalUser/index'
import fleet from '@/api/base/fleet/index'

export default {
  name: 'index',
  data() {
    return {
      driverData: {},
      driverQueryParams: {
        page: 1,//页码
        pageSize: 5,//页数
        fleetId: ''//车队编号
      },
      userAllData: [],
      flletData: []
    }
  },
  methods: {
    getDriverLicenseInfo(row) {
      console.log('----', row)
      driver.findOneDriverLicense(row.id).then(data => {

      })
    },
    handleSizeChange(val) {
      this.driverQueryParams.pageSize = val
      this.findAllDriver()
    },
    handleCurrentChange(val) {
      this.driverQueryParams.page = val
      this.findAllDriver()
    },
    findAllDriver() {
      driver.findAllDriver(this.driverQueryParams).then(data => {
        this.driverData = data.data
      })
    }, getUserAll() {
      user.queryAll().then(data => {
        this.userAllData = data.data
      })
    },
    getFleet() {
      fleet.findAll().then(data => {
        this.flletData = data.data
      })
    }
  },
  created() {
    this.findAllDriver()
    this.getUserAll()
    this.getFleet()
  }
}
</script>

<style scoped>

</style>
